#include "MainSurface.h"
#include "ui_MainSurface.h"
#include <Kernel/Screenshot.h>
#include <Kernel/MouseHandle.h>
#include <Kernel/KeyboardHandle.h>
#include <Kernel/Jump.h>
#include <Kernel/ShakeGun.h>
#include <Kernel/GunInfo.h>
#include <Kernel/TS.h>

MainSurface::MainSurface(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainSurface)
    , distinguish(new DistinguishSurface)
{
    Screenshot::init();
    MouseHandle::init();
    KeyboardHandle::init();
    GunInfo::init();
    ui->setupUi(this);
    ui->jump_Slider->setValue(Jump::get_step());
}

MainSurface::~MainSurface()
{
    delete ui;
    MouseHandle::shutdown();
    KeyboardHandle::shutdown();
}

void MainSurface::on_ScreenshotButton_clicked()
{
    ui->screen_shot_window->cut();
}

void MainSurface::on_jump_toggled(bool checked)
{
    if(checked){
        Jump::open();
    }else{
        Jump::close();
    }
}

void MainSurface::on_jump_Slider_valueChanged(int value)
{
    Jump::set_step(value);
}

void MainSurface::on_shake_gun_checkbox_toggled(bool checked)
{
    if(checked){
        ShakeGun::open();
    }else{
        ShakeGun::close();
    }
}

void MainSurface::on_gun_edit_clicked()
{
    distinguish->show();
}

void MainSurface::on_ts_toggled(bool checked)
{
    if(checked){
        TS::open();
    }else{
        TS::close();
    }
}
